<!DOCTYPE html>
<html lang="zh-Hans">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>点击开启/关闭浮层</title>
    <link rel="stylesheet" href="./style.css">
</head>

<body>
    <div class="wrapper">
        <button class="clickMe">点我开/关浮层</button>
        <div class="popover">
            <input type="checkbox">点我
            <span>不会</span> 关闭浮层
            <hr>
            点击浮层<span>以外</span>就会关闭浮层
        </div>
    </div>

    <script src="./jquery-3.3.1.min.js"></script>
    <script>
        $('.clickMe').on('click', function (e) {
            $('.popover').toggleClass('active')
            e.stopPropagation()
            setTimeout(function () {
                $(document).one('click', function () {
                    $('.popover').removeClass('active')
                })
            }, 0)
        })
        $('.popover').on('click', function (e) {
            e.stopPropagation()
        })
    </script>
</body>

</html>